<template>
  <button @click="isShow = true">展示弹窗</button>

  <!-- 弹窗-to到指定位置body，这样子你的modala元素就和outer元素是同一级的了 -->
  <teleport to="body">
    <div class="modala" v-show="isShow">
      <h2>我是弹窗的标题</h2>
      <p>我是弹窗的内容</p>
      <button @click="isShow = false">关闭弹窗</button>
    </div>
  </teleport>
</template>

<script setup lang="ts">
import { ref } from "vue";

let isShow = ref(false);
</script>

<style scoped>
.modala {
  width: 200px;
  height: 200px;
  background-color: rgb(138, 145, 145);
  border-radius: 10px;
  padding: 5px;
  box-shadow: 0 0 5px;
  text-align: center;
  position: fixed;
  left: 50%;
  top: 20px;
  transform: translateX(-50%);
}
</style>
